﻿/* ==============================================================================
 * 功能描述：MapConfigProvider  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/18 22:18:15
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

public class MapConfigProvider : BaseProvider<MapConfigProvider>
{
    private MapConfig mapConfig;

    public MapConfig MapConfig
    {
        get
        {
            if (mapConfig == null)
            {
                mapConfig = LoadConfig<MapConfig>("/xml/mapConfig.xml");
            }
            return mapConfig;
        }
    }

    public MapConfigMap[] GetAll()
    {
        return MapConfig.Items;
    }

    public MapConfigMap GetMapById(int id)
    {
        MapConfigMap map = System.Array.Find<MapConfigMap>(MapConfig.Items, (MapConfigMap obj) =>
        {
            return int.Parse(obj.id) == id;
        });
        if (map == null) Debug.Log("配置表中找不到该地图，id：" + id);
        return map;
    }
}